import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:x_common_utils/utils/inkWell_util.dart';
import 'package:get/get.dart';
import 'package:xinxuan/utils/color_util.dart';

/// 预约赎回
class RedeemDialog extends Dialog {

  final String price;
  final Function onTap;
  RedeemDialog({ required this.price, required this.onTap });

  @override
  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency,
      child: Center(
        child: Container(
          width: 320.w,
          decoration: BoxDecoration(
            color: bgWhiteColor,
            borderRadius: BorderRadius.circular(12.w)
          ),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Container(
                padding: EdgeInsets.symmetric(vertical: 32.h),
                child: Column(
                  children: [
                    Text(
                      '退款金额',
                      style: TextStyle(
                        color: textBlackColor,
                        fontSize: 18.sp,
                        fontWeight: FontWeight.bold
                      ),
                    ),
                    Text.rich(
                      TextSpan(
                        text: '¥',
                        style: TextStyle(
                          color: mainTextColor,
                          fontSize: 26.sp,
                          fontWeight: FontWeight.bold
                        ),
                        children: [
                          TextSpan(
                            text: '$price',
                            style: TextStyle(
                              color: mainTextColor,
                              fontSize: 30.sp,
                              fontWeight: FontWeight.bold
                            )
                          )
                        ]
                      )
                    ),
                    SizedBox(height: 20.h),
                    Text(
                      '您的金额将原路退回，预计一分钟内到账',
                      style: TextStyle(
                        color: textSubtitleColor,
                        fontSize: 14.sp
                      ),
                    )
                  ],
                ),
              ),
              Container(
                height: 55.h,
                decoration: BoxDecoration(
                  border: Border(
                    top: BorderSide(
                      width: .5,
                      color: lineColor
                    )
                  )
                ),
                child: Row(
                  children: [
                    InkWellUtil.shakeProofInkWell(Container(
                      width: 160.w,
                      height: 55.h,
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        border: Border(
                          right: BorderSide(
                            width: .5,
                            color: lineColor
                          )
                        )
                      ),
                      child: Text(
                        '取消',
                        style: TextStyle(
                          fontSize: 16.sp,
                          color: textSubtitleColor
                        ),
                      ),
                    ), () async {
                      Get.back();
                    },
                    hoverColor: Colors.transparent,
                    splashColor: Colors.transparent,
                    highlightColor: Colors.transparent),
                    InkWellUtil.shakeProofInkWell(Container(
                      width: 159.w,
                      height: 55.h,
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.only(
                          bottomRight: Radius.circular(12.w),
                        )
                      ),
                      child: Text(
                        '确定',
                        style: TextStyle(
                          fontSize: 16.sp,
                          color: mainTextColor
                        ),
                      ),
                    ), () async {
                      Get.back();
                      onTap();
                    },
                    hoverColor: Colors.transparent,
                    splashColor: Colors.transparent,
                    highlightColor: Colors.transparent)
                  ],
                )
              )
            ],
          )
        ),
      ),
    );
  }
}